package cn.cy.util;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.log4j.Logger;

import java.util.Map;

/**
 * 拦截未登陆的请求
 */
public class AuthorzationInterceptor extends AbstractInterceptor {
    private  static final Logger log  = Logger.getLogger(AuthorzationInterceptor.class);


    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        Map session = actionInvocation.getInvocationContext().getSession();

        log.info("请求带的参数---------"+actionInvocation.getResultCode());
        log.info("跳转前的结果---------"+actionInvocation.invokeActionOnly());
        log.info("请求来至于---------"+actionInvocation.getAction());
        if("" == null){
                log.info("未登录---------login");
                return "login";
            }else{
                return actionInvocation.invoke();
        }
    }
}
